package com.youlu.campus.admin.category;

import com.youlu.campus.common.base.RestResult;
import com.youlu.campus.common.base.RestResultBuilder;
import com.youlu.campus.entity.CategoryInfo;
import com.youlu.campus.entity.VO.req.CategoryQueryVO;
import com.youlu.campus.service.category.CategoryInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CategoryInfoController {

    @Autowired
    private CategoryInfoService categoryInfoService;

    @PostMapping("/category/save")
    public RestResult saveOrUpdate(@RequestBody CategoryInfo saveCategory){
        categoryInfoService.saveOrUpdate(saveCategory);
        return RestResultBuilder.builder().success(true).build();
    }

    @PostMapping("/category/list")
    public RestResult list(@RequestBody CategoryQueryVO categoryQuery){
        return RestResultBuilder.builder().success(true).data(categoryInfoService.list(categoryQuery)).build();
    }


}
